#!/bin/bash

set -e

Tumor=$1
Normal=$2

##################################################################
## 所有突变
Type=all

mkdir -p ${SigProfiler_path}/vcf/vcf_${Type}

## 产生bed文件
cat ${Images_path}/mutRate/MutShare.AllPoint.tsv | grep -w ${Tumor} | \
awk -F'\t' '{OFS="\t"}{print $3,$4-1,$5}' \
> ${tmp_path}/${Tumor}.${Type}.bed
## 提取bed文件
${bedtools} intersect -a ${vcf_path}/${Tumor}_${Normal}_GGA_Filter.vcf -b ${tmp_path}/${Tumor}.${Type}.bed -header \
> ${SigProfiler_path}/vcf/vcf_${Type}/${Tumor}_${Normal}.vcf

##################################################################
## Trunk突变
Type=trunk

mkdir -p ${SigProfiler_path}/vcf/vcf_${Type}

## 产生bed文件
cat ${Images_path}/mutRate/MutShare.AllPoint.tsv | grep -w ${Tumor} | \
awk -F'\t' '{OFS="\t"}{if($16=="TRUE")print $3,$4-1,$5}' \
> ${tmp_path}/${Tumor}.${Type}.bed
## 提取bed文件
${bedtools} intersect -a ${vcf_path}/${Tumor}_${Normal}_GGA_Filter.vcf -b ${tmp_path}/${Tumor}.${Type}.bed -header \
> ${SigProfiler_path}/vcf/vcf_${Type}/${Tumor}_${Normal}.vcf

##################################################################
## Private突变
Type=private

mkdir -p ${SigProfiler_path}/vcf/vcf_${Type}

## 产生bed文件
cat ${Images_path}/mutRate/MutShare.AllPoint.tsv | grep -w ${Tumor} | \
awk -F'\t' '{OFS="\t"}{if($16=="FALSE")print $3,$4-1,$5}' \
> ${tmp_path}/${Tumor}.${Type}.bed
## 提取bed文件
${bedtools} intersect -a ${vcf_path}/${Tumor}_${Normal}_GGA_Filter.vcf -b ${tmp_path}/${Tumor}.${Type}.bed -header \
> ${SigProfiler_path}/vcf/vcf_${Type}/${Tumor}_${Normal}.vcf
